Imports System
Imports System.Diagnostics

''' <summary>
''' Add and get information from the Windows Event Logs.
''' </summary>
Public Class EventLogUtil

#Region "Private constructor"

	Private Sub New()
		' Can't create instance!
	End Sub

#End Region

#Region "Write logs"

	''' <summary>
	''' Writes to the specified event log, passing all parameters.
	''' </summary>
	Public Shared Sub Write(ByVal logName As String, ByVal source As String, ByVal text As String, ByVal eventType As EventLogEntryType, ByVal eventId As Int32)

		If Not EventLog.Exists(logName) Or Not EventLog.SourceExists(source) Then
			EventLog.CreateEventSource(source, logName)
		End If

		Using evt As New EventLog(logName)

			evt.Source = source
			evt.WriteEntry(text, eventType, eventId)

		End Using
		
	End Sub

#End Region

End Class